Skip to content

chore: update Svelte tests to be more Testing Library-y#2174

Merged
crutchcorn merged 1 commit into
mainfrom
more-svelte-testing-library
May 11, 2026
Merged

chore: update Svelte tests to be more Testing Library-y#2174
crutchcorn merged 1 commit into
mainfrom
more-svelte-testing-library

Conversation

@crutchcorn
Copy link
Copy Markdown
Member

@crutchcorn crutchcorn commented May 11, 2026

The previous PR wasn't very TL-like with API usage. This PR fixes that

Summary by CodeRabbit

  • Tests
    • Updated test infrastructure to use modern testing practices with improved DOM selectors and query methods, enhancing test reliability and maintainability across the Svelte form test suite.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9e75599-0c0f-4660-af15-0b41185bb12b

📥 Commits

Reviewing files that changed from the base of the PR and between 087aee7 and d6a429f.

📒 Files selected for processing (7)
  • packages/svelte-form/tests/array-swap.svelte
  • packages/svelte-form/tests/array.svelte
  • packages/svelte-form/tests/array.test.ts
  • packages/svelte-form/tests/large.svelte
  • packages/svelte-form/tests/large.test.ts
  • packages/svelte-form/tests/simple.svelte
  • packages/svelte-form/tests/simple.test.ts

📝 Walkthrough

Walkthrough

The PR migrates Svelte form test files from raw DOM selectors to Testing Library best practices. Test component markup adds data-testid attributes, and test code refactors from querySelector queries to accessible Testing Library methods like getByLabelText, getByRole, and getByTestId.

Changes

Testing Library Migration

Layer / File(s) Summary
Array Test Components - Selector Updates
packages/svelte-form/tests/array.svelte, packages/svelte-form/tests/array-swap.svelte
Value display and button elements updated from id to data-testid attributes (val, push, swap).
Simple & Large Form Components - Selector Updates
packages/svelte-form/tests/simple.svelte, packages/svelte-form/tests/large.svelte
Form-state debug output updated from generic <pre> to <pre data-testid="form-state">.
Array Tests - Query Refactoring
packages/svelte-form/tests/array.test.ts
"should support array mode" and "swapFieldValues" tests refactored to use getByTestId('val') for value assertions and getByRole('button') for button interactions.
Large Form Tests - Query Refactoring
packages/svelte-form/tests/large.test.ts
Tests switch to getByLabelText('First name') for field lookup and parse form state from getByTestId('form-state').
Simple Form Tests - Query Refactoring
packages/svelte-form/tests/simple.test.ts
All five test cases refactored to use getByLabelText() for input fields, getByRole() for buttons, getByTestId('form-state') for state, and getByText()/queryByText() for validation messages.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 With data-testid now in place,
Testing Library queries embrace the space,
No more selector strife—just friendly names,
Accessible testing wins these games! 🧪✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is vague and does not provide sufficient detail about the changes, testing status, or release impact as required by the template. Expand the description to explain specific changes made (test file updates, selector changes), confirm testing via the checklist, and indicate whether this is a dev-only change.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: refactoring Svelte test files to adopt more Testing Library-idiomatic patterns and selectors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch more-svelte-testing-library

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented May 11, 2026

View your CI Pipeline Execution ↗ for commit d6a429f

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 8s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-11 00:02:01 UTC

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

More templates

@tanstack/angular-form

npm i https://pkg.pr.new/@tanstack/angular-form@2174

@tanstack/form-core

npm i https://pkg.pr.new/@tanstack/form-core@2174

@tanstack/form-devtools

npm i https://pkg.pr.new/@tanstack/form-devtools@2174

@tanstack/lit-form

npm i https://pkg.pr.new/@tanstack/lit-form@2174

@tanstack/preact-form

npm i https://pkg.pr.new/@tanstack/preact-form@2174

@tanstack/react-form

npm i https://pkg.pr.new/@tanstack/react-form@2174

@tanstack/react-form-devtools

npm i https://pkg.pr.new/@tanstack/react-form-devtools@2174

@tanstack/react-form-nextjs

npm i https://pkg.pr.new/@tanstack/react-form-nextjs@2174

@tanstack/react-form-remix

npm i https://pkg.pr.new/@tanstack/react-form-remix@2174

@tanstack/react-form-start

npm i https://pkg.pr.new/@tanstack/react-form-start@2174

@tanstack/solid-form

npm i https://pkg.pr.new/@tanstack/solid-form@2174

@tanstack/solid-form-devtools

npm i https://pkg.pr.new/@tanstack/solid-form-devtools@2174

@tanstack/svelte-form

npm i https://pkg.pr.new/@tanstack/svelte-form@2174

@tanstack/vue-form

npm i https://pkg.pr.new/@tanstack/vue-form@2174

commit: d6a429f

@crutchcorn crutchcorn merged commit 24ac6ca into main May 11, 2026
7 checks passed
@crutchcorn crutchcorn deleted the more-svelte-testing-library branch May 11, 2026 00:02
@sentry
Copy link
Copy Markdown

sentry Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.31%. Comparing base (6892ed0) to head (d6a429f).
⚠️ Report is 214 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2174      +/-   ##
==========================================
- Coverage   90.35%   86.31%   -4.04%     
==========================================
  Files          38        8      -30     
  Lines        1752       95    -1657     
  Branches      444        8     -436     
==========================================
- Hits         1583       82    -1501     
+ Misses        149       12     -137     
+ Partials       20        1      -19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant